ode_container Derived Type

type, public :: ode_container

A container for the routine containing the ODEs to integrate.


Components

Type Visibility Attributes Name Initial
procedure(ode), public, pointer, nopass :: fcn => null()

A pointer to the routine containing the ODEs to integrate.

procedure(ode_jacobian), public, pointer, nopass :: jacobian => null()

A pointer to the routine containing the analytical Jacobian. If supplied, this routine is utilized; however, if null, a finite difference approximation is utilized.

procedure(ode_mass_matrix), public, pointer, nopass :: mass_matrix => null()

A pointer to the routine containing the mass matrix for the system. If set to null (the default), an identity mass matrix will be assumed.


Type-Bound Procedures

procedure, public :: compute_jacobian => oc_jacobian

  • private subroutine oc_jacobian(this, x, y, jac, err)

    Computes the Jacobian matrix for the system of ODEs. If a routine is provided with an analytical Jacobian, the supplied routine is utilized; else, the Jacobian is estimated via a forward difference approximation.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_container), intent(inout) :: this

    The ode_container object.

    real(kind=real64), intent(in) :: x

    The current independent variable value.

    real(kind=real64), intent(in), dimension(:) :: y

    An N-element array containing the current dependent variable values.

    real(kind=real64), intent(out), dimension(:,:) :: jac

    An N-by-N matrix where the Jacobian will be written.

    class(errors), intent(inout), optional, target :: err

    An optional errors-based object that if provided can be used to retrieve information relating to any errors encountered during execution. If not provided, a default implementation of the errors class is used internally to provide error handling. Possible errors and warning messages that may be encountered are as follows.

    • DIFFEQ_MEMORY_ALLOCATION_ERROR: Occurs if there is a memory allocation issue.

    • DIFFEQ_NULL_POINTER_ERROR: Occurs if no ODE function is defined, and the calculation is being performed by finite differences.

    • DIFFEQ_MATRIX_SIZE_ERROR: Occurs if jac is not N-by-N.

procedure, public :: get_finite_difference_step => oc_get_fd_step

  • private pure function oc_get_fd_step(this) result(rst)

    Gets the size of the step to use for the finite difference calculations used to estimate the Jacobian.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_container), intent(in) :: this

    The ode_container object.

    Return Value real(kind=real64)

    The step size.

procedure, public :: get_is_mass_matrix_dependent => oc_get_is_mass_dependent

  • private pure function oc_get_is_mass_dependent(this) result(rst)

    Gets a value determining if the mass matrix is state-dependent such that it requires updating at every integration step.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_container), intent(in) :: this

    The ode_container object.

    Return Value logical

    True if the mass matrix is state-dependent such that it requires updating at each integration step; else, false if the mass matrix is not state-dependent and can be treated as constant for all integration steps.

procedure, public :: get_is_ode_defined => oc_get_is_ode_defined

  • private pure function oc_get_is_ode_defined(this) result(rst)

    Gets a logical value determining if the ODE routine has been defined.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_container), intent(in) :: this

    The ode_container object.

    Return Value logical

    True if the ODE routine has been defined; else, false.

procedure, public :: set_finite_difference_step => oc_set_fd_step

  • private subroutine oc_set_fd_step(this, x)

    Sets the size of the step to use for the finite difference calculations used to estimate the Jacobian.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_container), intent(inout) :: this

    The ode_container object.

    real(kind=real64), intent(in) :: x

    The step size.

procedure, public :: set_is_mass_matrix_dependent => oc_set_is_mass_dependent

  • private subroutine oc_set_is_mass_dependent(this, x)

    Sets a value determining if the mass matrix is state-dependent such that it requires updating at every integration step.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_container), intent(inout) :: this

    The ode_container object.

    logical :: x

    True if the mass matrix is state-dependent such that it requires updating at each integration step; else, false if the mass matrix is not state-dependent and can be treated as constant for all integration steps.